import Vue from 'vue';
import VueRouter from 'vue-router';
import Home from '@/views/Home.vue';

const originalPush = VueRouter.prototype.push;
VueRouter.prototype.push = function push(location) {
  return originalPush.call(this, location).catch((err) => err);
};
const originalReplace = VueRouter.prototype.replace;
VueRouter.prototype.replace = function replace(location) {
  return originalReplace.call(this, location).catch((err) => err);
};
Vue.use(VueRouter);

const routes = [
  {
    path: '/',
    name: 'Home',
    component: Home,
  },
  {
    path: '/account',
    name: 'Account',
    component: () => import('@/views/Account'),
  },
  {
    path: '/meal',
    name: 'Meal',
    component: () => import('@/views/Meal'),
  },
  {
    path: '/buy',
    name: 'Buy',
    component: () => import('@/views/Buy'),
  },
  {
    path: '/list',
    name: 'List',
    component: () => import('@/views/List'),
  },
  {
    path: '/register',
    name: 'Register',
    component: () => import('@/views/Register'),
  },
  {
    path: '/forget',
    name: 'Forget',
    component: () => import('@/views/Forget'),
  },
  {
    path: '/detail',
    name: 'Detail',
    component: () => import('@/views/Detail'),
  },
  {
    path: '/no',
    name: 'No',
    component: () => import('@/views/No'),
  },
  {
    path: '*',
    name: 'NotFound',
    component: () => import('@/views/NotFound'),
  },
  {
    path: '/test',
    component: () => import('@/views/test'),
  },
  {
    path: '/chatDetail',
    component: () => import('@/views/chatDetail'),
  },
  {
    path: '/intro',
    component: () => import('@/views/foot/Introduction'),
  },
  {
    path: '/privacy',
    component: () => import('@/views/foot/Privacy'),
  },
  {
    path: '/loading',
    component: () => import('@/views/threePart/Loading'),
  },
  {
    path: '/three/register',
    component: () => import('@/views/threePart/Register'),
  },
  {
    path: '/save',
    name: 'saveGoods',
    component: () => import('@/views/saveGoods'),
  },
  {
    path: '/edit/:id',
    name: 'editGoods',
    component: () => import('@/views/saveGoods'),
  },
  {
    path: '/useage',
    name: 'useage',
    component: () => import('@/views/foot/Usage'),
  },
  {
    path: '/foot/ad',
    name: 'AD',
    component: () => import('@/views/foot/AD'),
  },
  {
    path: '/foot/about',
    name: 'about',
    component: () => import('@/views/foot/About'),
  },
  {
    path: '/foot/car',
    name: 'car',
    component: () => import('@/views/foot/Car'),
  },
  {
    path: '/foot/prepay',
    name: 'Prepay',
    component: () => import('@/views/foot/Prepay'),
  },
  {
    path: '/foot/problem',
    name: 'Problem',
    component: () => import('@/views/foot/Problem'),
  },
  {
    path: '/foot/recharge',
    name: 'Recharge',
    component: () => import('@/views/foot/Recharge'),
  },
  {
    path: '/foot/meal',
    name: 'footMeal',
    component: () => import('@/views/foot/meal'),
  },
  {
    path: '/userAll/:username',
    name: 'UserAll',
    component: () => import('@/views/SalerList'),
  },
  {
    path: '/Pay/:id',
    name: 'pay',
    component: () => import('@/views/Pay'),
  },
  {
    path: '/OrderDetail/:id',
    name: 'pay',
    component: () => import('@/views/OrderDetail'),
  },
];

const router = new VueRouter({
  mode: 'history',
  base: process.env.BASE_URL,
  routes,
});

export default router;
